﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_addAdmin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["currentAdmin"] != null)
            {
                MODEL.Users user = new MODEL.Users();
                user = (MODEL.Users)Session["currentAdmin"];
                if (user.UserRoleId != 3)
                {
                    MessageBox.Show(this, "您没有添加管理员的权限");
                    MessageBox.script(this, "window.location='ListAllUsers.aspx';");
                }
            }
        }

    }

    #region 添加管理员
    /// <summary>
    /// 添加管理员
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void lBtnAddAdmin_Click(object sender, EventArgs e)
    {
        BLL.Users blluser=new BLL.Users();
        MODEL.Users user = new MODEL.Users();
        user.UName = txtAddAdmin.Text.Trim();
        user.Pwd = txtAddPwd.Text.Trim();
        user.Question = "";
        user.Answer = "";
        user.QQ = "";
        user.Email = "";
        user.Phone = "";
        user.UserRoleId = 2;
        if (blluser.AddAdmin(user))
        {
            MessageBox.Show(this, "添加成功");
            txtAddAdmin.Text = "";
            txtAddPwd.Text = "";
        }
        else
        {
            MessageBox.Show(this, "添加失败");
        }
    } 
    #endregion

}